package com.dianrui.fmi.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.dianrui.fmi.R;
import com.dianrui.fmi.interfaces.OnAskDialogCallBack;


public class CloseDialog {

    public static void createCloseDialog(final Context context, final OnAskDialogCallBack onAskDialogCallBack) {
        final Dialog dialog = new Dialog(context, R.style.RcDialog);
        View view = LayoutInflater.from(context).inflate(R.layout.close_ask, null);
        dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        TextView cancel_dialog_ask =view.findViewById(R.id.cancel_dialog_ask);
        final TextView yes_dialog_ask =view.findViewById(R.id.yes_dialog_ask);
        cancel_dialog_ask.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onAskDialogCallBack != null) {
                    onAskDialogCallBack.onCancel(dialog);
                }
            }
        });
        yes_dialog_ask.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onAskDialogCallBack != null) {
                    onAskDialogCallBack.onokey(dialog);
                }
            }
        });
        dialog.setCanceledOnTouchOutside(false);
        dialog.setContentView(view);
        dialog.show();

    }
}
